local hx__xingjie = fk.CreateSkill {
  name = "hx__xingjie",
  tags = { Skill.Limited },
}

hx__xingjie:addEffect(fk.EventPhaseStart, {
  anim_type = "drawcard",
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(hx__xingjie.name) and target.phase == Player.Start and player:usedSkillTimes(hx__xingjie.name,Player.HistoryGame) == 0
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local to = room:askToChoosePlayers(player, {
      targets = room:getOtherPlayers(player, false),
      min_num = 1,
      max_num = 1,
      prompt = "选择一名其他角色的获得其所有技能",
      skill_name = hx__xingjie.name,
      cancelable = false,
    })
    for _, p in ipairs(room:getOtherPlayers(player, false)) do
      room:addPlayerMark(p, "@@hx__xingjie_nil-turn", 1)
      room:addPlayerMark(p, "@@hx__xingjie_prohibit-turn", 1)
    end
    local skills = table.filter(to[1]:getSkillNameList(), function (s)
      if not player:hasSkill(s, true) then
        local skill = Fk.skills[s]
        if skill:hasTag(Skill.AttachedKingdom) then
          return table.contains(skill:getSkeleton().attached_kingdom, player.kingdom)
        else
          return true
        end
      end
    end)
    if #skills > 0 then
      room:handleAddLoseSkills(player, table.concat(skills, "|"))
    end
    room.logic:getCurrentEvent():findParent(GameEvent.Turn):addCleaner(function()
      room:handleAddLoseSkills(player, "-" .. table.concat(skills, "|-"))
    end)
    player:gainAnExtraTurn(false, hx__xingjie.name)
  end,
})

hx__xingjie:addEffect("invalidity", {
  invalidity_func = function(self, from, skill)
    return from:getMark("@@hx__xingjie_nil-turn") > 0 and skill:isPlayerSkill(from)
  end,
})


hx__xingjie:addEffect("prohibit", {
  prohibit_use = function(self, player, card)
    return card and player:getMark("@@hx__xingjie_prohibit-turn") > 0
  end,
  prohibit_response = function(self, player, card)
    return card and player:getMark("@@hx__xingjie_prohibit-turn") > 0
  end,
})

return hx__xingjie